#!/usr/bin/env python3
from datetime import datetime, timedelta

# Test the sorting function directly
def sort_priority(session_count, last_activity):
    last_activity_timestamp = last_activity.timestamp() if last_activity else 0
    session_weight = session_count * 1000
    recency_weight = last_activity_timestamp / 1000
    return session_weight + recency_weight

now = datetime.now()

# Test scenarios
scenarios = [
    ("Old but many sessions", 50, now - timedelta(days=7)),
    ("Recent but few sessions", 5, now - timedelta(hours=1)), 
    ("Moderate sessions and time", 20, now - timedelta(days=2))
]

print("Directory Priority Sorting Test:")
print("=" * 50)

results = []
for name, count, time in scenarios:
    priority = sort_priority(count, time)
    results.append((priority, name, count, time))
    
# Sort by priority (highest first)
results.sort(reverse=True)

for i, (priority, name, count, time) in enumerate(results, 1):
    print(f"{i}. {name}")
    print(f"   Sessions: {count}, Time: {time}")
    print(f"   Priority: {priority:.2f}")
    print()

print("✅ Test completed - directories sorted by session count + recency!")